Skip to content

feat(desktop): import from Chrome, Edge, Brave, Vivaldi, Opera, Arc and Firefox - #7260

Merged
juliusmarminge merged 23 commits into
browser-profile-importfrom
browser-import-more-sources
Sep 3, 2026
Merged

feat(desktop): import from Chrome, Edge, Brave, Vivaldi, Opera, Arc and Firefox#7260
juliusmarminge merged 23 commits into
browser-profile-importfrom
browser-import-more-sources

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Aug 16, 2026

Copy link
Copy Markdown
Member

Stacked on #7255 (browser-profile-import).

Expands cookie import to a source registry with Chromium and Firefox readers.

Source macOS Windows Linux in this layer
Chrome, Edge, Brave, Vivaldi, Opera Supported Unsupported Detected; key support in #7261
Arc, Helium Supported Unsupported Unsupported
Firefox Supported Supported Supported

Firefox imports its default container; other containers are excluded so their sessions are not mixed. Discovery respects profiles.ini, validates relative paths, supports explicitly configured absolute profile directories, and ignores fallback entries without a cookie database. Counts use the same default-container filter as the reader.

Both engines share a consistent read-only SQLite snapshot path. Windows Chromium remains intentionally unsupported, preserving the Windows-tested contribution #7323.

Validation: focused source-discovery, path-validation, Firefox cookie/count, and SQLite snapshot fixtures. Cross-platform path tests run on macOS; they are not a substitute for another live Windows/Linux test.

Original implementation: Claude Code. Review fixes: GPT-5.6 Sol agents, coordinated through Codex.

Note

Add browser cookie import for Chrome, Edge, Brave, Vivaldi, Opera, Arc, and Firefox

  • Expands BROWSER_IMPORT_SOURCE_IDS to include seven Chromium-based browsers and Firefox, with per-browser platform paths, keychain coordinates, and engine type (chromium vs firefox)
  • Adds Firefox cookie reading in readFirefoxCookies that snapshots cookies.sqlite read-only, decodes schema-version-aware moz_cookies rows (expiry unit changes at schema 16, rawSameSite migration for schemas ≤14), and filters to the default container
  • Adds Firefox profile discovery via parseFirefoxProfiles (profiles.ini parsing with path validation) plus cross-platform fallback directory scanning, including Linux Snap root deduplication
  • Adds Firefox running-state detection with platform-specific lock probes: firefoxSymlinkLockIsHeld + posixLockIsHeld (fcntl via child interpreter) on POSIX, windowsLockIsHeld (sharing violation on parent.lock) on Windows
  • Extracts shared ImportedCookie, CookieReadResult, cookieScope, bareHost, and snapshotCookieDatabase into CookieDatabase.ts for reuse by both engines
  • Risk: ChromiumCookies.sameSiteFromColumn now maps column value 1 and unknown values to unspecified instead of lax; Chromium import is blocked on non-macOS platforms via unsupportedPlatform in BrowserImport.ts

Macroscope summarized 4916613.


Note

Medium Risk
Touches cookie import, keychain access, and path validation across many browsers; Chromium SameSite mapping changed and Firefox lock probing can mis-detect running state if probes fail.

Overview
Expands desktop browser cookie import from a single Helium source to a registry of Chrome, Edge, Brave, Vivaldi, Opera, Arc, Helium, and Firefox, wired through contracts and user docs for Settings → Integrations.

Discovery and safety move to a shared BrowserImportPathContext (platform, home, Windows %APPDATA%). Chromium sources get per-fork paths and keychain IDs; Windows Chromium stays unsupported (App-Bound Encryption). Non-macOS Chromium is rejected at list/import time until other key stores exist. Firefox adds profiles.ini parsing with path hardening, directory fallback scanning, Linux Snap alongside native installs, symlink-following for cookie DB detection, and per-profile running checks (symlink lock, fcntl on .parentlock, Windows parent.lock).

Reading cookies is split by engine: shared CookieDatabase (WAL-safe snapshot, ImportedCookie / cookieScope) feeds Chromium (macOS keychain, refactored SameSite → unspecified where appropriate) and new Firefox (readFirefoxCookies — schema-aware expiry, rawSameSite, default-container-only). BrowserImport branches readers, skips false keychain audit logs for Firefox, and maps tagged read errors. HostProcessAddresses supports Firefox lock PID matching on local IPs.

Reviewed by Cursor Bugbot for commit eea4224. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f3c31f7b-c598-4238-adee-9242d001ce25

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Aug 16, 2026
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.3 KiB
Codex Live turn WebSocket wire 6.6 KiB 7.8 KiB
Codex Live turn WebSocket decoded 57.1 KiB 66.4 KiB
Codex Live turn messages 10 21
Claude Total thread wire 13.8 KiB 15.1 KiB
Claude Thread snapshot wire 7.0 KiB 7.3 KiB
Claude Live turn WebSocket wire 6.7 KiB 7.8 KiB
Claude Live turn WebSocket decoded 59.3 KiB 66.4 KiB
Claude Live turn messages 10 21

Baseline: unavailable · PR result: eea4224 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.8 KiB
  • Claude decoded thread snapshot: 114.5 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@juliusmarminge
juliusmarminge force-pushed the browser-import-more-sources branch from bc1215b to 973b17e Compare August 16, 2026 22:08
@github-actions github-actions Bot added the 📱 Native Change Changes the native fingerprint; merging blocks production OTAs until a new store build ships. label Aug 16, 2026

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One convention finding: the new Firefox cookie read path models its failure as an anonymous object literal instead of a Schema.TaggedErrorClass. Details inline.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/BrowserImport/BrowserImport.ts
Comment thread apps/desktop/src/preview/BrowserImport/CookieDatabase.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/FirefoxCookies.ts Outdated
@juliusmarminge
juliusmarminge marked this pull request as ready for review August 16, 2026 22:18
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts
@macroscopeapp

macroscopeapp Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces substantial production behavior for discovering browser profiles and importing authentication cookies from multiple browsers and platforms, including new database, keychain, process-lock, and DNS interactions. It also adds a static-analysis suppression directive, so the scope and review-sensitive handling require human review.

No code changes detected at 4916613. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge force-pushed the browser-import-more-sources branch from 973b17e to 1b132e4 Compare August 16, 2026 22:53
Comment thread apps/desktop/src/preview/BrowserImport/FirefoxCookies.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts
@juliusmarminge
juliusmarminge force-pushed the browser-import-more-sources branch from 3343565 to 56f1705 Compare August 16, 2026 23:10

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect service conventions: one finding on the new FirefoxCookieReadError. The tagged-error union fix from the previous round looks good; what remains is the structural context the error captures.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/BrowserImport/FirefoxCookies.ts
@juliusmarminge
juliusmarminge force-pushed the browser-import-more-sources branch from 56f1705 to 4d48bd9 Compare August 16, 2026 23:14
@juliusmarminge
juliusmarminge force-pushed the browser-import-more-sources branch from 4d48bd9 to 0d85caa Compare August 16, 2026 23:22
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts Outdated
@juliusmarminge
juliusmarminge force-pushed the browser-import-more-sources branch from 7a8cf25 to 27037c9 Compare August 16, 2026 23:51
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts
@juliusmarminge
juliusmarminge force-pushed the browser-import-more-sources branch from 27037c9 to 9328514 Compare August 16, 2026 23:59
@github-actions github-actions Bot removed the 📱 Native Change Changes the native fingerprint; merging blocks production OTAs until a new store build ships. label Aug 17, 2026
Comment thread apps/desktop/src/preview/BrowserImport/FirefoxCookies.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/FirefoxCookies.ts
Comment thread apps/desktop/src/preview/BrowserImport/FirefoxCookies.ts
Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/FirefoxCookies.ts
@macroscopeapp

macroscopeapp Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Macroscope skipped reviewing this pull request. Per-PR cost limit exceeded (workspace setting).

Reviews on this PR have cost $47.31 so far. This review would add an estimated $3.00, bringing the total to $50.31 — above your per-PR limit of $50.00.

Tip

To get this pull request reviewed, you can:

  1. Comment @macroscope-app on this PR to request a manual review (monthly spend limits still apply).
  2. Exclude large or generated files from review by adding a pattern to your .macroscope/ignore.md — note that creating this file replaces Macroscope's built-in default ignores rather than extending them.
  3. Raise your cost limit in your workspace billing settings.

Turn off this reminder going forward

juliusmarminge and others added 23 commits September 3, 2026 23:20
…Firefox

Generalises the importer from one hardcoded browser to a source registry with
two engines.

Chromium forks are table entries: Chrome, Edge, Brave, Vivaldi, Opera, Arc and
Helium all share the existing extractor and differ only in their paths and
keychain coordinates. Those coordinates are pinned per fork rather than
derived, because the forks disagree — Helium uses "Helium Storage Key" /
"Helium" where the others use "<Name> Safe Storage" / "<Name>".

Firefox is a second engine. It stores cookies unencrypted in `cookies.sqlite`,
so there is no key to fetch and no consent prompt — that is Mozilla's design
choice, not a control being circumvented, and it is why Firefox works
identically on all three platforms while Chromium still needs a per-platform
credential store.

Paths resolve for macOS, Windows and Linux from an injected context rather
than from `process`, so a platform's layout can be checked without running on
it. Chromium off macOS still reports `unsupportedPlatform` until those key
stores land; Firefox does not.

The snapshot-before-read step moves to a shared module, since both engines
keep the database open with WAL and must never have the browser's own file
opened for writing.

Firefox has tests against a real `moz_cookies` fixture, including that the
source file is left untouched, and `profiles.ini` parsing covers the
`Install*` sections that name a default profile without describing one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Firefox keeps its lock files inside each profile, not at the user-data root, so
the running check never found them and offered imports from a live, mid-write
database. It now walks the source's profiles and looks for all three names the
platforms use.

Firefox isolates cookies per container and per private window through
`originAttributes`. Electron has no equivalent, so importing them all collapsed
several identities onto one host/name/path and handed the profile whichever
container was written last. Only the default container is imported.

The sidecar copy no longer ignores every error alongside the missing-file case;
the new snapshot test caught that the earlier fix had landed on the
pre-extraction copy of this code rather than the shared module.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The Firefox branch failed with an anonymous `{ reason, cause }` literal, and
typing the shared `read` value as that shape erased `ChromiumCookieReadError`'s
tag from the error channel — neither branch could then be handled with
`Effect.catchTags`.

`FirefoxCookieReadError` mirrors its Chromium counterpart, so the union stays
structurally identifiable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Firefox keeps one cookie database per profile, so a failure carrying only a
reason cannot be traced back to the profile that produced it. The path is now a
structural attribute, matching `ChromiumCookieReadError`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Firefox has one failure mode — its plaintext database would not open — so a
single-value `reason` literal encoded the same thing as the tag, and `cause`
was optional though every construction site wraps a real failure. The error now
carries the database path and a required cause, and `BrowserImport` supplies
the user-facing reason where it maps the union.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The union was discriminated with a `cause._tag` ternary inside `Effect.mapError`
even though both members are statically known tagged errors; `Effect.catchTags`
says the same thing without the manual check. The comment above `read` claiming
both carry a `reason` was stale — Firefox's no longer does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Firefox schema 16 (Firefox 129) moved `moz_cookies.expiry` from seconds to
milliseconds — the migration is `UPDATE moz_cookies SET expiry = expiry * 1000`
— but the reader passed the value straight through as seconds, so persistent
cookies from a current Firefox were imported ~1000× too far in the future.
Older profiles still hold seconds, so the unit is decided by `PRAGMA
user_version` rather than assumed either way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… browser

`isSourceRunning` treated `.parentlock` / `parent.lock` as proof Firefox held
the profile, but Firefox deliberately leaves those on disk after a clean exit
(as a last-used marker) and only releases the OS-level fcntl or handle lock —
so once Firefox had been used, the source reported `browserRunning` forever and
cookie import never proceeded.

Verified against Firefox's nsProfileLock.cpp: only the Linux `lock` symlink
(target `<ip>:[+]<pid>`) is unlinked on exit, so its presence plus a live pid
is the POSIX signal; a dead pid means a crash. Node has no fcntl probe, so
`.parentlock` carries no signal on POSIX. On Windows the held handle denies our
open as `Busy`, which is the signal there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…s detected

Follow-ups to the leftover-lock fix. On macOS a running Firefox writes nothing
but an empty `.parentlock` held with an fcntl lock — no symlink, no pid — so
reading only the Linux `lock` symlink missed it entirely and offered imports
from a live, mid-write database. Node exposes no fcntl, so a throwaway
`python3` child tries a non-blocking F_SETLK and reports whether it blocks;
any failure to get a clean answer counts as held, so a probe problem can
never unlock a live profile. The Linux symlink still short-circuits first.

The symlink's owner half is honoured too: a non-loopback address is a shared
profile locked from another machine, whose pid cannot be probed here, so it
stays held. Also drops a Safari paragraph from `entryExists`' doc that
described `databaseFileExists`' concern, not this helper's.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… Windows lock probe

A Firefox import logged "Reading browser cookie key from the keychain" with the executable path even though it never touches a keychain, putting a false security-sensitive event in the audit trail; the log now sits behind the Chromium engine check. Also narrows isLockHeld to the Windows probe its doc describes (its only caller already guards on win32) and deletes entryExists, which that dead branch was the last use of.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ock symlink

The owner check treated only 127.0.0.1 and ::1 as ours, but Firefox writes
whatever its resolver returns for the machine's hostname — 127.0.1.1 on
Debian-style hosts, a LAN address elsewhere, loopback only when the lookup
fails. A crashed Firefox on such a host left a symlink the check read as
foreign and held forever, blocking import. The owner is now matched against
every address the machine answers to, via a new `HostProcessAddresses`
reference that mirrors `HostProcessHostname` and is injectable in tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…name-resolved addresses as local

Two follow-ups on the Firefox lock detection.

A Dock-launched app has launchd's bare PATH, so `python3` could go unfound;
the probe now names `/usr/bin/python3` absolutely first. More importantly,
"held" is now only ever the script's own verdict: a probe that never ran —
no interpreter, or Apple's shim on a Mac without the developer tools, which
exits non-zero after prompting to install — is the probe being unavailable,
not evidence about the lock, and falls back to "not held" rather than
blocking Firefox import on that machine for good. The SQLite snapshot copes
with a live WAL as it does for every other engine.

And `HostProcessAddresses` collected only interface addresses, so a
hostname mapped in /etc/hosts to an address no interface carries — Debian's
127.0.1.1 — read as foreign, holding a crashed Firefox's lock forever. The
set now also includes what the resolver returns for the machine's hostname,
which is exactly what Firefox writes into the lock.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Firefox stores nsICookie::SAMESITE_UNSET (256) for a cookie that carried no
SameSite attribute, distinct from SAMESITE_NONE (0), an explicit opt-in to
cross-site use. The reader collapsed the unknown value onto Lax, and the
reviewed suggestion would have made it None — both change the cookie's
meaning. `ImportedCookie` now carries Electron's own `unspecified`, which lets
the target browser apply its default exactly as the source did, and both
engines map their "no attribute" sentinel (Firefox 256, Chromium -1) to it.

Also drops a doubled `/**` opener left above `cookieDatabaseCandidatePaths`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rows from before schema 9 hold NULL in sameSite, which failed decoding
and aborted the whole import. Schemas 10-14 also keep the declared value
in rawSameSite beside a Lax default; apply Firefox's own schema-15
migration rule so an undeclared cookie imports as unspecified rather
than as an explicit Lax.
The hostname DNS lookup ran once per profile and even on Windows, where
the symlink lock that needs it never exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant